const express = require('express');
const handle = require('../router_handle/singer_handle');
const app = express.Router();
const multer = require('multer');
const path = require('path');
const storage = multer.diskStorage({
	destination: function (req, file, cb) {
		cb(null, path.join(__dirname, '../uploads/singer'));
	},
	filename: function (req, file, cb) {
		cb(null, 'singer' + new Date().valueOf() + path.extname(file.originalname));
	}
})
const upload = multer({
	storage
})

// 添加singer(post)
// /singer/addSinger
// name sex picfile introduction singerTypeId
app.post('/addSinger', upload.single("picfile"), handle.addSinger)
// 删除singer(get)
// /singer/deleteSinger
// id
app.get('/deleteSinger', handle.deleteSinger);
// 查看singer(get)
// /singer/getSinger
app.get('/getSinger', handle.getSinger);
// 修改singer(post)
// /singer/editSinger
// id name sex picfile introduction singerTypeId
app.post('/editSinger', upload.single("picfile"), handle.editSinger);
// 通过id获取singer(get)
// /singer/getSingerById
// id
app.get('/getSingerById', handle.getSingerById);
// 通过singertypeid获取singer(get)
// /singer/getSingerBySingerTypeId
// singertypeid
app.get('/getSingerBySingerTypeId',handle.getSingerBySingerTypeId)

// 添加singertype(post)
// /singer/addSingerType
// name create_time
app.post('/addSingerType', handle.addSingerType);
// 修改singertype(post)
// /singer/editSingerType
// id name(new)
app.post('/editSingerType', handle.editSingerType);
// 删除singertype(get)
// /singer/deleteSingerType
// id
app.get('/deleteSingerType', handle.deleteSingerType);
// 查看singertype(get)
// /singer/getSingerType
app.get('/getSingerType', handle.getSingerType);
// 根据id获取singertype
// /singer/getSingerTypeById
// id
app.get('/getSingerTypeById',handle.getSingerTypeById);


module.exports = app